<template>
	<!-- 底部菜单 -->
	<!-- <view class="commenMenu">
    <view v-for="_ in menus" v-if="!_.hidden" :class="{ check: checkIndex == _.index }" @click="goFun(_.path)">
      <u-icon :name="_.icon" size="42" style="margin-bottom: 6rpx"></u-icon>
      <text>{{ _.name }}</text>
    </view>
  </view> -->
	<view class="commenMenu">
		<view v-for="(item,index) in list" :key="index" @click="goFun(item.path)" :class="{'check':checkIndex==index}">
			<image :src="'../../static/newUi/icon'+(index+1)+'.png'" v-show="checkIndex!=index" />
			<image :src="'../../static/newUi/icon'+(index+1)+'_check.png'" v-show="checkIndex==index" />
			<text>{{ item.name }}</text>
		</view>
	</view>
</template>
<script>
	import {
		getMyInfo
	} from '@/utils/req/api.js'

	// const whitelist = ['18507144869', '13243871040', '13090891324', '13714838327'] // 测试白名单
	export default {
		props: ['checkIndex'],
		data() {
			return {
				userInfo: {},
				isSingle: uni.getStorageSync('orderType') == 'singleMode',
				list: [{
					name: '点餐',
					path: '/pages/home/index'
				}, {
					name: '我的',
					path: '/pages/my/my'
				}, ]
			}
		},
		computed: {
			menus: _this => {
				// const showStore1 = Object.values(uni.getStorageSync('YST_OrderUser')).some(_ => whitelist.includes(_))
				// const showStore2 = Object.values(_this.userInfo).some(_ => whitelist.includes(_)) // 测试白名单
				return [{
						index: 1,
						name: '首页',
						icon: 'home-fill',
						path: _this.isSingle ? '/pages/singleMode' : '/pages/index/index',
						hidden: true
					},
					{
						index: 3,
						name: '门店',
						icon: 'bell-fill',
						path: '/pages/placeOrder/placeOrder',
						hidden: true
					}, // TODO: del old page
					{
						index: 0,
						name: '点餐',
						icon: 'bell-fill',
						path: '/pages/home/index'
					},
					{
						index: 2,
						name: '我的',
						icon: 'account-fill',
						path: '/pages/my/my'
					},
				]
			},
		},
		mounted() {
			// this.getUserInfo()
		},
		methods: {
			goFun: url => uni.navigateTo({
				url
			}),
			async getUserInfo() {
				const {
					data
				} = await getMyInfo()
				this.userInfo = data.result
			},
		},
	}
</script>

<style lang="scss" scoped>
	.commenMenu {
		z-index: 99;
		position: fixed;
		// left: 0;
		bottom: 0;
		width: 100%;
		height: 120rpx;
		background-color: #fff;
		border-top: 1px solid #eee;
		@include flexs(space-around, center);

		>view {
			@include flexs(center, center);
			flex-direction: column;

			font-size: 26rpx;
			line-height: 1;
			// padding: 5rpx 0 15rpx 0;
			// color: #ccc;
			color: #58585a;

			font-size: 22rpx;
			line-height: 1;
			padding-bottom: 10rpx;

			image {
				width: 56rpx;
				height: 56rpx;
				margin-top: 10rpx;
				margin-bottom: 10rpx;
			}
		}

		>.check {
			// color: #fa690a;
			color: #FF4A37;
			font-weight: bold;
		}
	}
</style>